home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / SHDK_1.ARJ / TESTCMDL.PAS < prev    next >
Pascal/Delphi Source File  |  1992-03-25  |  3KB  |  102 lines

  1. {$N+,E+}
  2. program TestCmdL;
  3. {
  4.                        To test the ShCmdLin unit
  5.  
  6.                   Copyright 1991 Madison & Associates
  7.                           All Rights Reserved
  8.  
  9.          This program source file and the associated executable
  10.          file may be  used and distributed  only in  accordance
  11.          with the  provisions  described  on  the title page of
  12.                   the accompanying documentation file
  13.                               SKYHAWK.DOC
  14. }
  15.  
  16. uses
  17.   TpDos,
  18.   TpCrt,
  19.   ShCmdLin;
  20.  
  21. const
  22.   VT  : array[VtStr..VtInt] of string = ('String ',
  23.                                          'Real   ',
  24.                                          'Integer');
  25.  
  26. var
  27.   S1      : string;
  28.   Y       : SwRec;
  29.   Err     : Integer;
  30.   OT      : text;
  31.  
  32. procedure AnyKey;
  33.   begin
  34.     if HandleIsConsole(1) then begin
  35.       Write('Any key to continue...');
  36.       if ReadKey = #0 then ;
  37.       WriteLn;
  38.       end;
  39.     end;
  40.  
  41. function ValStr : string;
  42.   var
  43.     S2  : string;
  44.   begin
  45.     case Y.SwVal of
  46.       VtStr   : ValStr := Y.StrVal;
  47.       VtReal  : begin
  48.                   Str(Y.RealVal, S2);
  49.                   ValStr := S2;
  50.                   end;
  51.       VtInt   : begin
  52.                   Str(Y.IntVal, S2);
  53.                   ValStr := S2;
  54.                   end;
  55.       end;
  56.     end; {ValStr}
  57.  
  58. begin
  59.   if not OpenStdDev(OT, 1) then begin
  60.     WriteLn('Can''t open console device.');
  61.     Halt(1);
  62.     end;
  63.   S1  := string(Ptr(PrefixSeg, $80)^);
  64.   WriteLn(OT, ^M^J^M^J,'':8,'The command tail is');
  65.   WriteLn(OT, '':8, S1);
  66.   WriteLn(OT, '':8,'MaxAvail = ',MaxAvail);
  67.   WriteLn(OT, '':8,'MemAvail = ',MemAvail);
  68.   WriteLn(OT);
  69.   ClInit;
  70.   ClParse(Nil, false, [';', '-']+[ReadSwCh], [':', '='], Err);
  71.   WriteLn(OT, '':10, 'Error return = ', Err);
  72.   if ExistFile('DoPop') then
  73.     while PopSwitch(Y) do begin
  74.       WriteLn(OT, '':10, 'Name = ', Y.Name);
  75.       WriteLn(OT, '':10, 'Value type = ', VT[Y.SwVal]);
  76.       WriteLn(OT, '':10, 'Switch Value = ', ValStr);
  77.       WriteLn(OT, '':10, 'MaxAvail = ',MaxAvail);
  78.       WriteLn(OT, '':10, 'MemAvail = ',MemAvail);
  79.       WriteLn(OT);
  80.       AnyKey;
  81.       end {while}
  82.   else begin
  83.     while GetSwitch(Y) do begin
  84.       WriteLn(OT, '':10, 'Name = ', Y.Name);
  85.       WriteLn(OT, '':10, 'Value type = ', VT[Y.SwVal]);
  86.       WriteLn(OT, '':10, 'Switch Value = ', ValStr);
  87.       WriteLn(OT, '':10, 'MaxAvail = ',MaxAvail);
  88.       WriteLn(OT, '':10, 'MemAvail = ',MemAvail);
  89.       WriteLn(OT);
  90.       AnyKey;
  91.       end; {while}
  92.     ClClose;
  93.     end; {else}
  94.   WriteLn(OT, '':8, 'Final memory values.');
  95.   WriteLn(OT, '':8,'MaxAvail = ',MaxAvail);
  96.   WriteLn(OT, '':8,'MemAvail = ',MemAvail);
  97.   if Err <> 0 then begin
  98.     WriteLn(OT);
  99.       AnyKey;
  100.     end;
  101.   end.
  102.